#define _CRT_SECURE_NO_WARNINGS 1
#include<stdio.h>
#include<stdlib.h>
int cmp(const void* a, const void* b)
{
	return *(int*)a < *(int*)b;
}
int maximumProduct(int* nums, int numsSize) 
{
	qsort(nums, numsSize, sizeof(int), cmp);
	int i = 0;
	int sum1 = 1;
	int sum2 = nums[numsSize - 1] * nums[numsSize - 2] * nums[0];
	for (i = 0; i < 3; i++)
	{
		sum1 *= nums[i];
	}
	return sum1 > sum2 ? sum1 : sum2;
}
int main()
{
	int num[10];
	int n = 0;
	scanf("%d", &n);
	for (int i = 0; i < n; i++)
	{
		scanf("%d", &num[i]);;
	}
	int ret = maximumProduct(num, n);
	printf("%d\n", ret);
	return 0;
}